package com.gblog.gblog.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gblog.gblog.mapper.ClassifyMapper;
import com.gblog.gblog.entity.Classify;
import com.gblog.gblog.service.ClassifyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author yixin
 * @since 2024-05-07
 */
@RestController
@Slf4j
@RequestMapping("/classify")
public class ClassifyController {

    @Autowired
    private ClassifyService classifyService;

    @Autowired
    private ClassifyMapper classifyMapper;


    // 获取所有分类
    @GetMapping("/list")
    public List<Classify> getClassifyList() {
        LambdaQueryWrapper<Classify> lambdaQueryWrapper = new LambdaQueryWrapper<>();

        lambdaQueryWrapper.isNotNull(Classify::getName);
        long count = classifyService.count(lambdaQueryWrapper);
        log.info(count + "");
        return classifyMapper.selectList(null
        );
    }

}

